home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Internet Surfer 2.0
/
Internet Surfer 2.0 (Wayzata Technology) (1996).iso
/
pc
/
text
/
mac
/
faqs.263
< prev
next >
Wrap
Text File
|
1996-02-12
|
28KB
|
644 lines
Frequently Asked Questions (FAQS);faqs.263
in the New Uploads file area, named GNUEMACS.ZIP
NOTE: Use the -d option of [pk]unzip for all .zip archives. Some sites
have Demacs lharc'ed. If you need to find programs to unpack lharc and -
zip format archives, Chris Dean <ctdean@talaris.com> points out that you
should see the comp.compression FAQ, available for FTP: !
/rtfm.mit.edu:pub/usenet/comp.compression/ !
Mailing list:
NOTE: There is no mailing list for Demacs. However, there is a list
for DJGPP, which is the environment that Demacs runs in. Many
Demacs problems are actually issues with DJGPP.
DJGPP:
Subscriptions:
To: listserv@sun.soe.clarkson.edu
body: add <your-address> djgpp
or put `help' in the body.
If this fails, mail to djgpp-request@sun.soe.clarkson.edu.
Submissions:
djgpp@sun.soe.clarkson.edu
FAQ list:
Maintainer: Dave Steibel <steibel@cs.umbc.edu>
Anonymous FTP: algol.cs.umbc.edu:pub/demacs/demacs.faq
123: Freemacs -- a small Emacs for MS-DOS
Author: Russ Nelson <nelson@sun.soe.clarkson.edu>
Latest released version: 1.6a
Anonymous FTP:
/simtel20.army.mil:PD:<MSDOS.FREEMACS> {ange-ftp syntax?} !
/grape.ecs.clarkson.edu:pub/msdos/freemacs/ !
Via e-mail:
To: archive-server@sun.soe.clarkson.edu
body: help
Via snail mail:
address: Russell Nelson, 11 Grant St., Potsdam, NY 13676
Send $15 copying fee, and specify preferred floppy disk format:
5.25", 360K, or 3.50", 720K
Mailing lists:
Subscriptions:
To: listserv@sun.soe.clarkson.edu
body: add <your-address> <name-of-list>
or put `help' in the body.
List distribution addresses:
freemacs-announce@sun.soe.clarkson.edu
freemacs-help@sun.soe.clarkson.edu
freemacs-workers@sun.soe.clarkson.edu (send bug reports here)
124: Patch -- program to apply "diffs" for updating files
Author: Larry Wall <lwall@netlabs.com>
Latest version: 2.0 patchlevel 12u8 !
(This is the version that supports the new unified diff format.)
Anonymous FTP:
/prep.ai.mit.edu:pub/gnu/patch-2.0.12u8.tar.Z !
/prep.ai.mit.edu:pub/gnu/patch-2.0.12g8.tar.Z (GNU version) +
Xref: bloom-picayune.mit.edu gnu.emacs.help:7402 comp.emacs:15251 news.answers:3116
Path: bloom-picayune.mit.edu!enterpoop.mit.edu!snorkelwacker.mit.edu!eff!sol.ctr.columbia.edu!spool.mu.edu!hri.com!noc.near.net!news.bbn.com!bu.edu!bigbird!jbw
From: jbw@bigbird.bu.edu (Joe Wells)
Newsgroups: gnu.emacs.help,comp.emacs,news.answers
Subject: GNU Emacs FAQ (4/5, 125-151): Keybindings/Output
Summary: READ BEFORE POSTING. A regularly posted list of answers to frequently
asked questions (FAQs) about GNU Emacs and many Emacs Lisp programs.
Contains pointers to other resources. Follow "References:" link for
more metainfo.
Keywords: gnu emacs faq answers frequently asked questions periodic
Message-ID: <GNU-Emacs-FAQ-4.1992.09.22.011020@bigbird.bu.edu>
Date: 22 Sep 92 01:10:20 GMT
Expires: 21 Nov 92 01:10:20 GMT
References: <GNU-Emacs-FAQ-0.1992.09.22.011020@bigbird.bu.edu>
Sender: news@bu.edu
Reply-To: gnu-emacs-faq-maintainers@bigbird.bu.edu
Followup-To: poster
Organization: GNU's Not UNIX
Lines: 975
Approved: news-answers-request@mit.edu
Supersedes: <GNU-Emacs-FAQ-4.1992.06.28.234430@bigbird.bu.edu>
Archive-Name: GNU-Emacs-FAQ/part4
Last-Modified: Mon, 21 Sep 1992 03:20:49 GMT
Last-Posted: Tue, 22 Sep 1992 01:10:20 GMT
GNU Emacs FAQ: Keybindings/Output
If you are viewing this text in a GNU Emacs Buffer, you can type "M-2 C-x $" to
get an overview of just the questions. Then, when you want to look at the text
of the answers, just type "C-x $".
To search for a question numbered XXX, type "M-C-s ^XXX:", followed by a C-r if
that doesn't work, then type ESC to end the search.
A `+' in the 78th column means something was inserted on the line. A `-' means
something was deleted and a `!' means some combination of insertions and
deletions occurred.
Full instructions for getting the latest FAQ are in question 22. Also see the
`Introduction to news.answers' posting in the `news.answers' newsgroup, or send
e-mail to `mail-server@rtfm.mit.edu' with `help' on a body line, or use FTP,
WAIS, or Prospero to rtfm.mit.edu.
Changing Key Bindings and Handling Key Binding Problems
125: How do I bind keys (including function keys) to commands?
1. Find out what character sequence is generated by the keystroke sequence
you wish to bind to a command. See question 129 for how to do this.
Keep in mind that the character sequences generated by a keystroke
sequence varies from one terminal to another. You may also get
different results depending on what type of machine you are running on
(see question 128). For example, these keystrokes may generate these
character sequences:
F1 ---> ESC [ 2 2 4 z
Shift-R10 ---> ESC O t
L7 ---> ESC [ 3 1 ~
Remove ---> C-@
2. Figure out what the Emacs Lisp syntax is for this character sequence.
Inside an Emacs Lisp string, RET, LFD, DEL, ESC, SPC, and TAB are
specified with `\r', `\n', `\C-?', `\e', ` ', and `\t'. C-x is
specified by `\C-x'. M-x is specified the same was as "ESC x".
(Control characters may also be specified as themselves, but I don't
recommend it.) An Emacs Lisp string begins and ends with the double
quote character, `"'. Here are some examples:
ESC [ D ---> "\e[D"
ESC [ 2 2 7 z ---> "\e[227z"
ESC [ 1 8 ~ ---> "\e[18~"
C-M-r ---> "\e\C-r"
3. If some prefix of the character sequence is already bound, you must
unbind it by binding it to `nil'. For example:
(global-set-key "\e[" nil)
4. Pick a command to bind your key sequence to. A command can be a
"symbol" with a function definition, or a "lambda list", or a string
(which is treated as a macro). For example:
(global-set-key "\e[D" 'backward-char)
(global-set-key "\e[227~" "\exgoto-line\r") ; macro
See `Key Bindings' and `Rebinding' in the online manual.
In Emacs 19 (including Lucid Emacs), you can bind function key F24 like +
this: +
+
(global-set-key 'f24 'some-command) +
126: Why does Emacs say `Key sequence XXX uses invalid prefix characters'?
A prefix of the character sequence you were trying to bind was already
bound. Usually, the sequence is "ESC [", in which case you should
evaluate this form first:
(define-key esc-map "[" nil)
NOTE: By default, "ESC [" is bound to backward-paragraph, and if you do
this you will lose this key binding. For most people, this is not a
problem.
See question 125.
127: Why doesn't this [terminal or window-system setup] code work in my
.emacs file, but it works just fine after Emacs starts up?
This is because you're trying to do something in your .emacs file that
needs to be postponed until after the terminal/window-system setup code
is loaded. This is a result of the order in which things are done
during the startup of Emacs. For more details see question 135.
In order to postpone the execution of Emacs Lisp code until after the
terminal/window-system setup, set the value of the variable
term-setup-hook or window-setup-hook to be a function which does what
you want.
See etc/OPTIONS for a complete explanation of what Emacs does every time
it is started.
Here is a simple example of how to set term-setup-hook:
(setq term-setup-hook
(function
(lambda ()
(cond ((string-match "\\`vt220" (or (getenv "TERM") ""))
;; Make vt220's "Do" key behave like M-x:
(define-key CSI-map "29~" 'execute-extended-command))
))))
128: How do I use function keys under X Windows?
This depends on whether you are running Emacs inside a terminal emulator
window, or whether you are allowing Emacs to create its own X window.
You can tell which you are doing by noticing whether Emacs creates a new
window when you start it.
If you are running Emacs inside a terminal emulator window, then it
behaves exactly as it does on any other tty. In this case, for function
keys to be useful, they must generate character sequences that are sent
to the programs running inside the window as input. The `xterm' program
has two different sets of character sequences that it generates when
function keys are pressed, depending on the sunFunctionKeys X resource
and the -sf and +sf command line options. (To find out what these key
sequences are, see question 129.) In addition, with xterm,
you can override what key sequence a specific function key (or any other
key) will generate with the `translations' resource. This, for example:
XTerm.VT100.Translations: #override \
<KeyPress>F1: string(0x1b) string("[xyzzy")
makes the function key F1 generate the character sequence "ESC [xyzzy".
On the other hand, if Emacs is managing its own X window, the following
description applies. Emacs receives `KeyPress' events from the X server
when a key is pressed while the keyboard focus is in its window. The
KeyPress event contains an X "keysym" code, which is simply an arbitrary
number corresponding to the name of the keysym, and information on which
"modifiers" such as `control' and `shift' are active. For example, the
`Tab' keysym is 0xff09. (Generally, a key on the keyboard will generate a
keysym whose name is the same as the label on the key, ie. the `Tab' key
will normally generate the `Tab' keysym. This can be changed with the
xmodmap program.) Emacs recognizes all the keysyms that correspond to
standard ASCII characters and internally uses the ASCII character instead.
(WARNING: I am about to describe a gross, disgusting hack to you, have
your barf bag ready.)
When Emacs receives the X keysym of one of the arrow keys, it behaves
the same as if it had received a letter key with the control modifier
down as follows (this is hard-coded):
Up becomes C-p
Down becomes C-n
Right becomes C-f
Left becomes C-b
The way Emacs treats other keysyms depends on what kind of machine it was
compiled on. The type of the display machine is irrelevant! Function
keys are mapped internally to escape sequences, while other keys are
completely ignored.
1. If compiled on a Sun, Emacs recognizes these X keysyms that
are normally on a Sun keyboard:
F1 through F9
L1 through L10 (same as F11 through F20)
R1 through R15 (same as F21 through F35)
(The keys labelled R8, R10, R12, and R14 usually are mapped to the
X keysyms Up, Left, Right, and Down.)
Break (the `Alternate' key is given this keysym)
These keys work like Sun function keys. When Emacs recieves the
keysym, it will internally use character sequences that look like "ESC
[ ### z", where ### is replaced by a number. The character sequences
are identical to those generated by Sun's keyboard under SunView. Any
function key not listed above generates "ESC [ - 1 z".
In order to use these key sequences, they should be bound to commands
using the standard key binding methods, just as if Emacs were running
on a regular terminal.
WARNING: F11 and L1 are the same keysym in X, as are F12 and L2, etc.
{Yes, this is stupid. Complain to the X consortium.}
2. If not compiled on a Sun, the function keys will appear to Emacs in a
way remarkably similar to the keys of a DEC LK201 keyboard (used on
some VT series terminals). These X keysyms will be recognized:
F1 through F20
Help (treated same as F15)
Menu (treated same as F16, is the LK201 `Do' key)
Find
Insert (LK201 `Insert Here' key)
Select
Prior (LK201 `Prev Screen' key *** ONLY IN 18.58 AND LATER ***)
Next (LK201 `Next Screen' key *** ONLY IN 18.58 AND LATER ***)
And finally, the LK201 key labelled `Remove' (or `Delete') is often
mapped to the Delete keysym which generates the DEL character (C-?)
instead of the key sequence given by the LK201 `Remove' key. It may
also be mapped to some other keysym, such as `_Remove', in which case
you can't use it from within Emacs at all.
Each function key will be internally converted to a character sequence
that looks like "ESC [ ## ~", where ## is replaced by a number. The
character sequences are identical to those generated by a LK201
keyboard. Any function key not listed above generates "ESC [ - 1 ~".
For the complete list of the numbers which are generated by the function
keys, look in the file src/x11term.c at the definitions of the function
stringFuncVal.
If you are running Emacs on a Sun machine, even if your X display is
running on a non-Sun machine (eg., an X terminal), you get the setup
described above for Suns. The determining factor is what type of
machine Emacs is running (was compiled) on, not what type of machine
your X display is on.
If you have function keys not listed above on your keyboard, you can use
`xmodmap' to change their keysym assignments to get keys that Emacs will
recognize, but that may screw up other programs.
X resources are not used by Emacs to affect the key sequences generated.
In particular, there are no X key "translations" for Emacs.
If you have function keys not listed above and you don't want to use
xmodmap to change their names, you might want to make a modification to
your Emacs. Johan Vromans <jv@mh.nl> has made available a patch for Emacs
that adds the x-rebind-key function of Epoch to Emacs 18.58. This allows
another layer of key rebinding before Emacs even sees the keys, and in
this layer you can rebind all of the keys and modifier combinations as
well.
Anonymous FTP:
/ftp.eu.net:gnu/emacs/FP-Xfun.Z +
/ftp.urc.tue.nl:pub/tex/emacs/FP-Xfun +
Johan Vromans explains what this buys for you:
After implementing this, all keyboard keys can be configured to send
user definable sequences, eg.,
(x-rebind-key "KP_F1" 0 "\033OP")
This will have the keypad key PF1 send the sequence "ESC O P", just like
an ordinary VT series terminal.
129: How do I tell what characters my function or arrow keys emit?
Use this function by Randal L. Schwartz <merlyn@iwarp.intel.com>:
(defun see-chars ()
"Displays characters typed, terminated by a 3-second timeout."
(interactive)
(let ((chars "")
(inhibit-quit t))
(message "Enter characters, terminated by 3-second timeout.")
(while (not (sit-for 3))
(setq chars (concat chars (list (read-char)))
quit-flag nil)) ; quit-flag maybe set by C-g
(message "Characters entered: %s" (key-description chars))))
Alternatively, use the "C-h l" view-lossage command, which will display
the last 100 characters Emacs has seen in its input stream. Kevin
Gallagher <kgallagh@digi.lonestar.org> suggests typing some unique string
like "wxyz", typing the key in question, then typing "C-h l". The
characters that appear between "wxyz" and "C-h l" were generated by the
key.
130: How do I set the X key "translations" for Emacs?
Sorry, you can't; there are no "translations" to be set. Emacs is not
written using the Xt library. The only way to affect the behavior of keys
within Emacs is through `xmodmap' (outside Emacs) or `define-key' (inside
Emacs).
131: How do I handle C-s and C-q being used for flow control?
C-s and C-q are used in the XON/XOFF flow control protocol. This screws
up Emacs because it binds these characters to commands. Also, by default
Emacs will not honor them as flow control characters and may overwhelm
output buffers. Sometimes, intermediate software using XON/XOFF flow
control will prevent Emacs from ever seeing C-s and C-q.
Possible solutions:
* Disable the use of C-s and C-q for flow control.
You need to determine what is the cause of the flow control.
* your terminal
Your terminal may use XON/XOFF flow control to have time to display
all the characters it receives. For example, VT series terminals do
this. It may be possible to turn this off from a setup menu. For
example, on a VT220 you may select `No XOFF' in the setup menu. This
is also true for some terminal emulation programs on PCs.
When you turn off flow control at the terminal, you will also need to
turn it off at the other end, which might be at the computer you are
logged in to or at some terminal server in between.
If you turn off flow control, characters may be lost; using a printer
connected to the terminal may fail. You may be able to get around
this problem by modifying the `termcap' entry for your terminal to
include extra NUL padding characters.
* a modem
If you are using a dialup connection, the modems may be using XON/XOFF
flow control. I don't know how to get around this.
* a router or terminal server
Some network box between the terminal and your computer may be using
XON/XOFF flow control. It may be possible to make it use some other
kind of flow control. You will probably have to ask your local
network experts for help with this.
* tty and/or pty devices
If your connection to Emacs goes through multiple tty and/or pty
devices, they may be using XON/XOFF flow control even when it is not
necessary.
Eirik Fuller <eirik@theory.tn.cornell.edu> writes:
Some versions of `rlogin' (and possibly telnet) do not pass flow
control characters to the remote system to which they connect. On
such systems, Emacs on the remote system cannot disable flow control
on the local system. Sometimes `rlogin -8' will avoid this problem.
One way to cure this is to disable flow control on the local host
(the one running rlogin, not the one running rlogind) using the stty
command, before starting the rlogin process. On many systems, `stty
start u stop u' will do this.
Some versions of `tcsh' will prevent even this from working. One
way around this is to start another shell before starting rlogin,
and issue the stty command to disable flow control from that shell.
Use `stty -ixon' instead of `stty start u stop u' on some systems.
* Make Emacs speak the XON/XOFF flow control protocol.
You can make Emacs treat C-s and C-q as flow control characters by
evaluating this form:
(set-input-mode nil t)
If you are fixing this for yourself, simply put the form in your .emacs
file. If you are fixing this for your entire site, the best place to
put it is unclear. I don't know if this has any effect when used in
lisp/site-init.el when building Emacs; I've never tried that. {Can
someone tell me whether it works?} Putting things in users' .emacs files
has a number of problems.
Putting this form in lisp/default.el has the problem that if the user's
.emacs file has an error, this will prevent lisp/default.el from being
loaded and Emacs may be unusable for the user, even for correcting their
.emacs file (unless they're smart enough to move it to another name). A
possible solution is to initially disable C-s and C-q by setting
keyboard-translate-table in lisp/site-init.el, either with swap-keys
(see question 136) or with the following form:
;; by Roger Crew <crew@cs.stanford.edu>:
(setq keyboard-translate-table
"\C-@\C-a\C-b\C-c\C-d\C-e\C-f\C-g\C-h\C-i\C-j\C-k\C-l\C-m\C-n\C-o\C-p\C-^\C-r\C-\\\C-t\C-u\C-v\C-w\C-x\C-y\C-z\C-[\C-s\C-]\C-q\C-_")
This will at least prevent Emacs from being confused by the flow control
characters, even if lisp/default.el cannot be loaded. Then, in
lisp/default.el, enable XON/XOFF flow control with set-input-mode.
For further discussion of this issue, read the file PROBLEMS in the
Emacs distribution.
132: How do I use commands bound to C-s and C-q (or any key) if these keys
are filtered out?
I suggest swapping C-s with C-\ and C-q with C-^:
(swap-keys ?\C-s ?\C-\\)
(swap-keys ?\C-q ?\C-^)
See question 136 for the implementation of swap-keys. This method
has the advantage that it simultaneously swaps the characters everywhere
throughout Emacs, while just switching the keybindings will miss important
places where the character codes are stored (eg., the search-repeat-char
variable, major mode keymaps, etc.).
To do this for an entire site, you may want to swap the keys in
lisp/default.el. If only some of your users are connecting through
XON/XOFF flow-controlled connections, you will want to do this
conditionally. I suggest pre-swapping them in lisp/site-init.el when
Emacs is built, and then in lisp/default.el, if it is determined to be
safe, they can be reenabled (being careful not to screw up any other key
mappings users might have established using keyboard-translate-table).
See question 131 for an easy way to pre-swap these keys.
WARNING: If you do this for an entire site, the users will be confused by
the disparity between what the documentation says and how Emacs actually
behaves.
133: Why does the `BackSpace' key invoke help?
The BackSpace key (on every keyboard I've used) generates ASCII code 8.
C-h sends the same code. In Emacs by default C-h invokes help-command.
This is intended to be easy to remember since the first letter of "help"
is "h". The easiest solution to this problem is to use C-h (and
BackSpace) for help and DEL (the Delete key) for deleting the previous
character.
For many people this solution may be problematic:
* They normally use BackSpace outside of Emacs for deleting the previous
character typed. This can be solved by making DEL be the command for
deleting the previous character outside of Emacs. This command will do
this on many Unix systems:
stty erase '^?'
* The person may prefer using the BackSpace key for deleting the previous
character because it is more conveniently located on their keyboard or
because they don't even have a separate Delete key. In this case, the
BackSpace key should be made to behave like Delete. There are several
methods.
* Under X Windows, the easiest solution is to change the BackSpace key
into a Delete key like this:
xmodmap -e "keysym BackSpace = Delete"
* Some terminals (eg., VT3## terminals) allow the character generated by
the BackSpace key to be changed from a setup menu.
* You may be able to get a keyboard that is completely programmable.
* Under X or on a dumb terminal, it is possible to swap the BackSpace
and Delete keys inside Emacs:
(swap-keys ?\C-h ?\C-?)
See question 136 for the implementation of swap-keys.
* Another approach is to switch keybindings and put help on "C-x h"
instead:
(global-set-key "\C-h" 'delete-backward-char)
(global-set-key "\C-xh" 'help-command) ; override mark-whole-buffer
Other popular key bindings for help are M-? and "C-x ?".
WARNING: Don't try to bind DEL to help-command, because there are many
modes that have local bindings of DEL that will interfere. -
134: Why doesn't Emacs look at the stty settings for Backspace vs. Delete?
Good question!
135: Why don't the arrow keys work?
When Emacs starts up, it doesn't know anything about arrow keys at all
(except when running under X, see question 128). During the process of
starting up, Emacs will load a terminal-specific initialization file for
your terminal type (as determined by the environment variable TERM), if
one exists. This file has the responsibility for enabling the arrow keys.
There are several things that can go wrong:
1. There is no initialization file for your terminal.
You can determine this by looking in the lisp/term directory. If your
terminal type (as determined by the TERM environment variable) is
xxx-yy-z, then the first of these files in the lisp/term directory will
be loaded as the terminal-specific initialization file: xxx-yy-z.el,
xxx-yy.el, or xxx.el.
There are two major cases of this problem:
* Your terminal type is very similar to one that has an init file.
In this case, there are several techniques suggested by Colin Jensen
<cjensen@ampex.com>, Ben Liblit <Liblit@cs.psu.edu>, and Marc
Auslander <marc@watson.ibm.com>:
A. Add a symbolic link in lisp/term for your terminal type that
points to the similar type. For example, you could make VT102
terminals work with this command:
ln -s vt100.el vt102.el
This fixes things for everyone on the system who uses the terminal
type.
B. If you can't do the solution in part A, you can add code to your
term-setup-hook that loads the correct file like this:
(setq term-setup-hook
(function
(lambda ()
(cond ((equal "vt102" (or (getenv "TERM") ""))
(load (concat term-file-prefix "vt100")))
(;; Code for other terminal types goes here ...
)))))
C. If you use `tset' to set your TERM environment variable when you
login, you can use the `-m' switch to tell tset to use a terminal
type known by Emacs instead of another similar one. For example,
specifying this:
tset ... -m 'dec-vt220:vt220' ...
will make tset say you are on a `vt220' instead of a `dec-vt220'.
D. Interactively, you can type "M-x load-library RET term/vt100" to
load the terminal-specific initialization files for VT100
terminals.
* Your terminal type is not similar to one that has an init file.
One can be made for your terminal, or you can just add code to your
own .emacs to handle this problem for yourself. For example, if your
terminal's arrow keys send these character sequences:
Up: ESC [ A
Down: ESC [ B
Right: ESC [ C
Left: ESC [ D
then you can bind these keys to the appropriate commands with code in
your .emacs like this:
(setq term-setup-hook
(function
(lambda ()
(cond ((string-match "\\`xyzzy" (or (getenv "TERM") ""))
;; First, must unmap the binding for left bracket
(or (keymapp (lookup-key global-map "\e\["))
(define-key global-map "\e\[" nil))
;; Enable terminal type xyzzy's arrow keys:
(define-key global-map "\e\[A" 'previous-line)
(define-key global-map "\e\[B" 'next-line)
(define-key global-map "\e\[C" 'forward-char)
(define-key global-map "\e\[D" 'backward-char))
((string-match "\\`abcde" (or (getenv "TERM") ""))
;; Do something different for terminal type abcde
;; .....
)))))
NOTE: You may have to restart Emacs to get changes to take effect.
NOTE: Your arrow keys may send sequences beginning with "ESC O" when
Emacs is running, even if they send sequences beginning with "ESC [" at
all other times. This is because Emacs uses any command there may be
in your terminal's termcap entry for putting the terminal into
"Application Keypad Mode". Just map these sequences the same way as
above.